package com.xinlong.service.impl;

import com.xinlong.dao.Iproductdao;
import com.xinlong.dao.RouteMapper;
import com.xinlong.entity.product;
import com.xinlong.service.productservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class productserviceimpl implements productservice {

    @Autowired
    private Iproductdao iproductdao;

    @Autowired
    private RouteMapper routeMapper;



    public List<product> productSelect() throws Exception {
        List<product> products = iproductdao.productSelect();
        return products;
    }

    public void save(product produc) throws Exception {
        iproductdao.save(produc);
    }

    public List<product> findByproductStatus(Integer status) {
        List<product> products = iproductdao.findByproductStatus(status);
        return products;
    }

    public void delproduct(Integer id) {
        routeMapper.delByPid(id);
        iproductdao.delproduct(id);
    }

    public void upproduct(product product) {
        iproductdao.upproduct(product);
    }

    public product findById(String id) {
        return iproductdao.findById(id);
    }


    public void updateStatus(){
        iproductdao.updateStatus2();
        iproductdao.updateStatus3();
    }

    @Override
    public Map selNumber(Integer productId) {
        return iproductdao.selProductNumber(productId);
    }

}
